// AspectsExecutable.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdio.h>

#include "..\Infobus\Infobus.h"

int _tmain(int argc, _TCHAR* argv[])
{
  if (2 == argc) {
    std::stringstream ss;
    std::ifstream myReadFile;
    myReadFile.open(argv[1], std::ifstream::binary);

    myReadFile.seekg(0, std::ios::end);
    int size = myReadFile.tellg();
    myReadFile.seekg(0);

    char* output = new char[size+1];
    memset(output, 0, size+1);
    if (myReadFile.is_open()) {
      myReadFile.read(output, size);
      ss << output;
    }
    myReadFile.close();    
    delete[] output;

#ifdef _DEBUG
    std::stringstream ssout;
    ssout << "File["<< argv[1] <<"]" << std::endl
          << ss.str().c_str()
          << std::endl;
    printf("%s", ssout.str().c_str());
#endif

    Dispatcher * pDisp = new Dispatcher(TRACES);
    if (pDisp) pDisp->sendMessage(ss.str().c_str());
    delete pDisp;
  } else {
    printf("%s", "Usage: AspectsExecutable [path] message.xml");
  }
  exit(0);
}

